package org.jxc.web.action;

import java.util.Date;
import java.util.List;

import org.jxc.domain.Warehouse;
import org.jxc.service.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import org.team4.exception.CRUDException;
import org.team4.util.LoginBean;
import org.team4.web.action.GenericAction;


@Controller
@Scope("prototype")
public class WarehouseAction extends GenericAction<Warehouse> {

    private static final long serialVersionUID = -4867867482994497216L;

    @Autowired
    private WarehouseService warehouseService ;
    private List<Warehouse> list;
    private Warehouse object;


    public String listPagination() throws Exception {
        page = warehouseService.listPagination(page, null);
        return SUCCESS;
    }

    public String toSave(){
    	return SUCCESS;
    }
    
    public String toUpdate() throws CRUDException{
    	object = warehouseService.findById(object.getId());
    	return SUCCESS;
    }
    
    public String update() throws CRUDException{
    	warehouseService.update(object);
    	return SUCCESS;
    }
    
    public String delete() throws CRUDException{
    	warehouseService.deleteWarehouse(object.getId());
    	return SUCCESS;
    }  
    
    public String save() throws CRUDException{
    	object.setCreator(LoginBean.getLoginBean().getUser());
    	object.setCreateTime(new Date());
    	warehouseService.save(object);
    	return SUCCESS;
    }

	public List<Warehouse> getList() {
		return list;
	}


	public Warehouse getObject() {
		return object;
	}

	public void setObject(Warehouse object) {
		this.object = object;
	}
}